<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
  	<title>本店菜单</title>
  	<%@ include file="../include/jsCss.jsp" %> 
  </head>
  <body>
  	<form action="mealmenu!mealMenuList.html" method="post" id="frmMealBoxList">
		本店菜单
		<hr />
		<table width="100%">
			<tr>
				<td width="50">编号</td>
				<td width="100"><input type="text" name="id"/></td>
				<td width="100">菜肴名称</td>
				<td width="100"><input type="text" name="menuName" /></td>
				<td width="100">菜品类别</td>
				<td>
					<s:select id="menuTypeId" name="menuTypeId" headerKey="" headerValue="请选择" list="#{1:'主食',2:'饮料',3:'凉菜'}"></s:select>
				</td>
				<td><input type="button" value="搜索" onclick="selectMealMenuList();"/></td>
				<td width="500" style="text-align: right;">
					<a href="mealmenu!mealMenu.html">添加菜肴</a>      |
					<a href="javascript:;" onclick="sellMealMenu(true);">已售完</a> 	    |
					<a href="javascript:;" onclick="sellMealMenu(false);">未售完</a>
				</td>
			</tr>
		</table>

		<table width="100%" border="1">
			<tr>
				<td rowspan="1" ><input type="checkbox" name="sellCheckBoxAll" onclick="chkAllSellCheckBox(this);"/></td>
				<td>是否售完</td>
				<td>编号</td>
				<td>菜肴名称</td>
				<td>价格</td>
				<td>口味</td>
				<td>菜肴类别</td>
				<td>排序号</td>
				<td>是否推荐</td>
				<td>介绍</td>
				<td>操作</td>
			</tr>
			<s:iterator value="mealMenuList">
				<tr>
					<td>
						<input type="checkbox" name="sellCheckBox" value="${id}" />
					</td>
					<td>
						<s:if test="isSell == true">
							已售完
						</s:if>
						<s:else>
							未售完
						</s:else>
					</td>
					<td>
						${mealMenuId }
					</td>
					<td>
						${menuName }
					</td>
					<td>
						${price }
					</td>
					<td>
						<s:if test="taste == 0">
							不辣
						</s:if>
						<s:if test="taste == 1">
							香辣
						</s:if>
						<s:if test="taste == 2">
							香辣(可选)
						</s:if>
						<s:if test="taste == 3">
							微辣
						</s:if>
					</td>
					<td>
						<s:if test="menuTypeId == 1">
							主食
						</s:if>
						<s:elseif test="menuTypeId == 2">
							饮料
						</s:elseif>
						<s:elseif test="menuTypeId == 3">
							凉菜
						</s:elseif>
						<%-- <s:if test="taste == 1">
							川菜
						</s:if>
						<s:elseif test="taste == 2">
							湘菜
						</s:elseif>
						<s:elseif test="taste == 3">
							粤菜
						</s:elseif>--%>
					</td>
					<td>
						${orderBy }
					</td>
					<td>
						<s:if test="isRecommend == true">
							推荐
						</s:if>
						<s:else>
							不推荐
						</s:else>
					</td>
					<td>
						${introduce }
					</td>
					<td><a href="mealmenu!mealMenu.html?id=${id }">修改</a> | <a href="javascript:;" onclick="deleteMealMenu(${id})">删除</a></td>
				</tr>
			</s:iterator>
		</table>
		<div>
			<jsp:include page="../include/page.jsp"></jsp:include> 
		</div>
	</form>
		<script>
			function chkAllSellCheckBox(t){
				$("input[name='sellCheckBox']").each(function(i,item){
					item.checked = t.checked;
				});
			}
			
			//点击搜索按钮 进行查询
			function selectMealMenuList(){
				$("#frmMealBoxList").submit();
			}
		
			function deleteMealMenu(id) {
				var dt = new Date();
				$.ajax( {
					type : "POST",
					url : "mealmenu!mealMenuDelete.html",
					data : "id=" + id + "&date=" + dt,
					success : function(data) {
						if ($.trim(data) == 0) {
							alert('删除成功');
							document.location.reload();
						}
					}
				});
			}
			
			function sellMealMenu(issell) {
				var id = "";
				$("input[name='sellCheckBox']").each(function(i, item) {
					if(item.checked == true){
						id += item.value + ",";
					}
				});
				
				var dt = new Date();
				$.ajax( {
					type : "POST",
					url : "mealmenu!mealMenuSell.html",
					data : "ids=" + id + "&sell="+issell+"&date=" + dt,
					success : function(data) {
						if ($.trim(data) == 0) { 
							alert('操作成功');
							document.location.reload();
						}
					}
				});
			}
		</script>
	</body>
</html>